package com.njxxted.activiti.common.util;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.njxxted.activiti.modules.api.entity.PushVo;
import com.njxxted.activiti.modules.process.extend.entity.ExtendActInstanceEntity;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.identity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * 描述：推送工具类
 * <p>
 * 作者：Ostrich Hu
 * 时间：2020/1/2 16:54 星期四
 */
public class PushUtils {

    protected static Logger logger = LoggerFactory.getLogger(PushUtils.class);

    public static PushVo convertPushParam(User user,
                                          String noticeType,
                                          String remark,
                                          DelegateTask delegateTask,
                                          Map<String, Object> conditionMap) {
        PushVo pushVo = null;
        try {
            pushVo = new PushVo();
            pushVo.setBusinessId(delegateTask.getProcessInstanceId());
            pushVo.setStartClientId(UserUtil.getUserFromRedis().getId());
            pushVo.setAcceptClientId(user.getId());
            pushVo.setTypes(noticeType);
            pushVo.setRemark(remark);
            pushVo.setStatus(0);
            pushVo.setDestination("/queue/specUser");
            pushVo.setConditionMap(JSON.toJSONString(conditionMap));
        } catch (Exception e) {
            logger.error("对象转为Map出错{}", e.toString());
        }
        return pushVo;
    }

    public static PushVo convertPushParam(String acceptClientId,
                                          String noticeType,
                                          String remark,
                                          String instanceId,
                                          Map<String, Object> conditionMap) {
        PushVo pushVo = null;
        try {
            pushVo = new PushVo();
            pushVo.setBusinessId(instanceId);
            pushVo.setStartClientId(UserUtil.getUserFromRedis().getId());
            pushVo.setAcceptClientId(acceptClientId);
            pushVo.setTypes(noticeType);
            pushVo.setRemark(remark);
            pushVo.setStatus(0);
            pushVo.setDestination("/queue/specUser");
            pushVo.setConditionMap(JSON.toJSONString(conditionMap));
        } catch (Exception e) {
            logger.error("对象转为Map出错{}", e.toString());
        }
        return pushVo;
    }
}
